/*
 * Parser for the configuration file. For now, it will be simply 
 * a plain text file with one parameter per line, except for the
 * phase coordinates.
 * 
 * TODO: add HFD5 and Python integration.
 * 
 */
 
  #include <stdlib.h>
  #include <stdio.h>
  #include <math.h>
  
  #include <common.h>
  
  int parse_config_file( FILE *stream, SIM_DATA *s ) {
	
	if( stream == NULL ) {
      fprintf( stderr, "ERROR. CANNOT PARSE CONFIGURATION FILE. ABORTING.\n" );
	  return -4;
	}
	
	// Miscelleanous parameters
	// -----------------------------------------------------------------
	fscanf( stream, "%d",   &s->id ); //Simulation ID
	fscanf( stream, "%ld",  &s->N  ); //Total number of bodies
	fscanf( stream, "%ld",  &s->N_active  ); //Total number of non-ghost bodies
	fscanf( stream, "%ld",  &s->N_ghosts  ); //Total number of ghost bodies
	fscanf( stream, "%d" ,  &s->container ); //Container of the simulation
	
	int i;
	for( i=0; i<9; i++ )
	  fscanf( stream, "%lf", &s->container_params[i] ); //Parameters of the container
	
	fscanf( stream, "%d",  &s->allow_outlayers ); //Whether or not to let particles move out of the simulation box  
	// -----------------------------------------------------------------
	
	// Timestep scheme parameters
	fscanf( stream, "%lf %lf %lf %lf", &s->eta, &s->dtnext, &s->tcrit, &s->eps2 ); 
      
    return 0;
  }
